﻿$(document).ready(function () {
    hideValidationMessage();
});

function loginValidation() {
    var isValid = true;
    if (isNullOrEmpty($("#username").val())) {
        $("#username").attr("class", "mce error wd_220");
        displayValidationMessage("error", "Please fill all required fields highlighted in red");
        $("#username").parent().next().attr("style", "display:visible");
        $("#username").parent().next().attr("title", "User Name is required");
        isLogin('false');
        isValid = false;
    } else {
        $("#username").attr("class", " mce wd_220");
		 $("#username").parent().next().attr("style","display:none");		
    }
    if (isNullOrEmpty($("#password").val())) {
        $("#password").attr("class", "mce error wd_220");
        displayValidationMessage("error", "Please fill all required fields highlighted in red");
        $("#password").parent().next().attr("style", "display:visible");
        $("#password").parent().next().attr("title", "Password is required");
        isLogin('false');
        isValid = false;
    } else {
        $("#password").attr("class", " mce wd_220");
		 $("#password").parent().next().attr("style","display:none");		
    }
    if (isValid == true) {
        if ($("#username").val() == "ElementTester@Nidec-MCE.com"
            && $("#password").val() == "init1234"){
        	isLogin('true');
            return true;
        }else {
            displayValidationMessage("error", "You have entered an invalid username or password!");
            isLogin('false');
            return false;
        }
    }
    /* Hide message */
    return isValid;
}
 
function isLogin(login){
	document.cookie ='isloggined='+login;
}